import React from 'react';
import request from 'umi-request';
import axios from 'axios';
import Classification from '../classification/classification';
import widthHook from '../component/widthhook';
import Swiper from '../swiper/swiper'
class Category extends React.Component{
    constructor(props){
        super(props)
        this.state={
            id:'',
            bannerList:[],
            categoryList:[]
        }
    }
    componentDidMount(){
        request.get('https://apipc-xiaotuxian-front.itheima.net/home/banner').then((res)=>{
            if(res){
                this.setState({
                    bannerList:res.result
                })
            }
        })
        axios.get(`https://apipc-xiaotuxian-front.itheima.net/category?id=${window.location.href.split('?',2)[1]}`).then(res=>{
            if(res.data){
                console.log(res);
                this.setState({
                    categoryList:res.data.result
                })
            }
        })
    }

    componentWillReceiveProps(){
        console.log(123);
    }
    render(){
        const {id,bannerList,categoryList} = this.state
        console.log(categoryList);
        return(
            <div className='category'>
                <Swiper  bannerList={bannerList}></Swiper>
                <Classification></Classification>
                {/* <h1>分类{id}</h1> */}
            </div>
        )
    }
}
const A = widthHook(Category)
export default A